package Thread;
//Runnable 匿名内部类。降低代码耦合
public class Demo4 {
    public static void main(String[] args) throws InterruptedException {
        Runnable r = new Runnable(){
            @Override
            public void run() {
                while(true){
                    System.out.println("Thread running...");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        };
        Thread t1 = new Thread(r);
        t1.start();
        while(true){
            System.out.println("Main running...");
            Thread.sleep(1000);
        }
    }
}
